﻿using System.Collections.Generic;
using Comdiv.QWeb.Serialization.BxlParser;

namespace Comdiv.QWeb.Test.Serialization.BxlParserTest {
	public static class TokenizerTestHelper {
		public static string getShortTypedNotation(IEnumerable<BxlToken> t , string rn = "\r\n") {
			var result = "";
			foreach (var token in t) {
				var c = getTypeString(token);
				if (c != "\n") result += c;
				else result += rn;
			}
			return result;
		}

		private static string getTypeString(BxlToken t) {
			switch (t.Type) {
				case BxlTokenType.Start :
					return "{";
				case BxlTokenType.Finish:
					return "}";
				case BxlTokenType.Literal:
					return "L";
				case BxlTokenType.String:
					return "S";
				
				case BxlTokenType.Attribute:
					return "A";
				case BxlTokenType.Element:
					return "E";
				case BxlTokenType.Value:
					return "V";
				case BxlTokenType.Level:
					return t.Number.ToString()[0].ToString();
				case BxlTokenType.Comma:
					return ",";
				case BxlTokenType.Assign:
					return "=";
				case BxlTokenType.Colon:
					return ":";
				case BxlTokenType.NewLine:
					return "\n";
				case BxlTokenType.Expression :
					return "X";
				case BxlTokenType.AttributeStart:
					return "A_";
				case BxlTokenType.AttributePart:
					return "_A_";
				case BxlTokenType.AttributeEnd:
					return "_A";
				case BxlTokenType.ValueStart:
					return "V_";
				case BxlTokenType.ValuePart:
					return "_V_";
				case BxlTokenType.ValueEnd:
					return "_V";
				default :
					return "?";
			}
		}
	}
}